#pragma once

#include "Definitions.h"
#include <map>
#include <string>
//#include "Structures.h"

#define NUMCONSTBUFFS 3
#define NUMVERTBUFFS 4

class Renderable;
class View;

class DirectX11
{
	static DirectX11* instance;

	ID3D11Device* device;
	ID3D11RenderTargetView* rtv;
	ID3D11DepthStencilView* dsv;
	ID3D11DeviceContext* deviceContext;
	ID3D11DeviceContext* deferredContext;
	ID3D11CommandList* commandList;
	IDXGISwapChain* swapChain;
	D3D11_VIEWPORT viewport;

	ID3D11RenderTargetView* postProcessRTV;
	ID3D11DepthStencilView* postProcessDSV;
	D3D11_VIEWPORT postProcessViewport;
	ID3D11VertexShader* postProcessVS;
	ID3D11GeometryShader* postProcessGS;
	ID3D11PixelShader* postProcessPS;
	ID3D11VertexShader* lightRepresentationVS;
	ID3D11GeometryShader* lightRepresentationGS;
	ID3D11PixelShader* lightRepresentationPS;
	ID3D11ShaderResourceView* postProcessTexture;
	ID3D11SamplerState* samplerState;

	//Arrays
	ID3D11Buffer* buffers[NUMVERTBUFFS];
	ID3D11Buffer* constantBuffers[NUMCONSTBUFFS];

	std::map<std::string,ID3D11ShaderResourceView*> textures;

	DirectX11(void);
	~DirectX11(void);
	DirectX11(const DirectX11&);
	DirectX11& operator=(const DirectX11&);

public:

	enum ConstBuffSlots {CB_OBJECT,CB_CAMERA,CB_LIGHT};

	static DirectX11* GetInstance();
	void DeleteInstance();

	bool Initialize(HWND hWnd);
	bool Shutdown();

	void Draw(Renderable* object,View* camera);

	ID3D11Device* GetDevice() {return device;}
	ID3D11DeviceContext* GetImmediateContext() {return deviceContext;}

	bool Render();
	void RenderDebug(View* camera);

	void SetConstantBuffer(ID3D11Buffer** buffer,ConstBuffSlots slot);
	void LoadTexture(wchar_t* fileName,std::string key);
	ID3D11ShaderResourceView* GetTexture(std::string key) {return textures[key];}

	void InitializePostProcessStuff();

};

